package com.soul.controller;

import com.soul.soulcommon.dto.ResetPwd;
import com.soul.soulcommon.result.Result;
import com.soul.soulservice.email.imp.EmailServiceImp;
import com.soul.soulservice.email.imp.ResetPwdServiceImp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@CrossOrigin
@RestController
@Tag(name = "邮箱验证码服务")
@RequestMapping("/email")
public class EmailController {
    @Autowired
    private EmailServiceImp emailService;
    @Autowired
    private ResetPwdServiceImp resetPwdService;
    @Operation(summary = "获取邮箱验证码", description = "需要在网址后面添加完整邮箱")
    @GetMapping("/get/{email}")
    public Result getEmailCode(@PathVariable String email){
        emailService.sendEmailCode(email);
        return Result.success("发送验证码成功");
    }
    @Operation(summary = "校验邮箱验证码", description = "通过json传递给接口")
    @PostMapping("/check")
    public Result checkEmailCode(@RequestBody @Valid ResetPwd resetPwd){
        return resetPwdService.checkCode(resetPwd);
    }
}
